#include<bits/stdc++.h>
using namespace std;
#define int long long

int s[5], w[5][25];
int f[5][1000];
int sum[5];

signed main() {
	for (int i = 1; i <= 4; i++)
		cin >> s[i];

	int ans = 0;
	for (int t = 1; t <= 4; t++) {
		for (int i = 1; i <= s[t]; i++)
			cin >> w[t][i], sum[t] += w[t][i];

		for (int i = 1; i <= s[t]; i++) {
			for (int j = sum[t] / 2; j >= w[t][i]; j--)
				f[t][j] = max(f[t][j - w[t][i]] + w[t][i], f[t][j]);
		}
		int mx = *max_element(&f[t][1], &f[t][sum[t] / 2 + 1]);
		ans += max(sum[t] - mx, mx);
//		cout << "!!!!   " << ans << "   !!!!" << endl;
	}
	cout << ans;
	return 0;
}
